const std = @import("std");
const os = @import("../os.zig");
const udp = os.net.udp;
const Proc = os.proc.Proc;
const gpa = std.heap.page_allocator;

pub fn send(p: *Proc, sport: u16, dst: u32, dport: u16, buf: [*]u8, size: usize) !void {
    const total = udp.Udp.packet_lenth + size;
    if (total > os.PGSIZE) return error.MessageTooBig;
    const buffer = try gpa.alloc(u8, total);
    @memset(buffer, 0);

    var reader = p.reader(.auto, &.{}, buf);
    try reader.io_r.readSliceAll(buffer[udp.Udp.packet_lenth..]);
    try udp.send(buffer, size, sport, dst, dport);
}

pub fn recv(p: *Proc, dport: u16, src: *u32, sport: *u16, buf: [*]u8, size: usize) !void {
    _ = p;
    _ = dport;
    _ = src;
    _ = sport;
    _ = buf;
    _ = size;
}

pub fn bind(p: *Proc, port: u16) !void {
    _ = p;
    _ = port;
}

pub fn unbind(p: *Proc, port: u16) !void {
    _ = p;
    _ = port;
}
